//
//  BIDEvaluateForPersonalRepairViewController.m
//  HJGJCommunity
//
//  Created by mal on 2017/6/9.
//  Copyright © 2017年 mal. All rights reserved.
//

#import "BIDEvaluateForPersonalRepairViewController.h"
#import "BIDOwnerPersonalRepairListViewController.h"
#import "BIDEvaluateView.h"
#import "BIDCustomTextView.h"

static NSString *evaluateURL = @"client/repair/confirmOrJudge.action";

@interface BIDEvaluateForPersonalRepairViewController ()

@end

@implementation BIDEvaluateForPersonalRepairViewController
@synthesize repairID;

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"评价";
    // Do any additional setup after loading the view from its nib.
    _contentTextView.inputAccessoryView = self.toolBar;
    _contentTextView.placeholder = @"请填写评语……";
    _contentTextView.layer.borderWidth = 1.f;
    _contentTextView.layer.borderColor = RGBACOLOR(193.f, 193.f, 193.f, 1.f).CGColor;
    //_evaluateView = [[BIDEvaluateView alloc] init];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)submitBtnHandler:(id)sender
{
    NSString *strContent = _contentTextView.text;
    NSUInteger score = [_evaluateView getScore];

    NSString *strRequestURL = [[NSString alloc] initWithFormat:@"%@/%@", [AppDelegate getPayServerAddr], evaluateURL];
    NSString *strPost = [[NSString alloc] initWithFormat:@"id=%@&status=3&confirmContent=%@&confirmLevel=%ld", repairID, strContent, score];
    [self sendHttpRequestWithURL:strRequestURL postData:strPost withCompletion:^(NSDictionary *responseDic, NSString *errMsg){
        if(errMsg)
        {
            [self showAlertView:errMsg buttonTitle:ALERT_BTN_TITLE tag:0 functionName:nil];
        }
        else
        {
            [self showAlertView:@"操作成功" buttonTitle:ALERT_BTN_TITLE tag:@100 functionName:@"alertViewHandler"];
        }
    }];
}

- (void)alertViewHandler
{
    NSArray *arr = self.navigationController.viewControllers;
    for(UIViewController *vc in arr)
    {
        if([vc isKindOfClass:[BIDOwnerPersonalRepairListViewController class]])
        {
            [self.navigationController popToViewController:vc animated:YES];
            break;
        }
    }
}

@end
